##!/usr/bin/env python3
# -*- coding: utf-8 -*-

from functools import reduce


def add(x, y, f):
    return f(x) + f(y)


print(add(10, -10, abs))


def fn(x, y):
    return 10 * x + y


def charToInt(n):
    d = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
    return d[n]


print(reduce(fn, map(charToInt, '12345678')))

print(reduce(lambda x, y: x * 10 + y, map(charToInt, '12345678')))
